part of '../repository.dart';

class _CustomCollectionListItemDataDtoFactory {
  const _CustomCollectionListItemDataDtoFactory._internal();

  static const _instance = _CustomCollectionListItemDataDtoFactory._internal();

  factory _CustomCollectionListItemDataDtoFactory() {
    return _instance;
  }

  _CustomCollectionListItemDataDto fromJson(Map<String, dynamic> json) {
    final type = json[_kCustomLexicalItemTypeKey] as String;

    switch (type) {
      case _kCustomCollectionDataTypeValue:
        return _CustomCollectionDataDto.fromJson(json);
      case _kCustomCollectionFolderTypeValue:
        return _CustomCollectionFolderDataDto.fromJson(json);
      default:
        throw UnimplementedError();
    }
  }

  _CustomCollectionListItemDataDto fromEntity(
      BackupCustomCollectionListItemData customCollectionListItem) {
    switch (customCollectionListItem) {
      case BackupCustomCollectionData():
        return _CustomCollectionDataDto.fromEntity(customCollectionListItem);
      case BackupCustomCollectionFolderData():
        return _CustomCollectionFolderDataDto.fromEntity(customCollectionListItem);
    }
  }
}
